<template>
   <div class="itemMusicList">
     <div class="itemListTop" v-if="subscribed">
       <div class="listLeft">
         <svg t="1690730738780" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2240" width="200" height="200"><path d="M819.498667 584.832L343.168 875.904A85.333333 85.333333 0 0 1 213.333333 803.114667V220.885333a85.333333 85.333333 0 0 1 129.834667-72.789333l476.330667 291.072a85.333333 85.333333 0 0 1 0 145.664z" fill="#000000" p-id="2241"></path></svg>
         <span class="quanbu" @click="PlayAll">播放全部<span>(共{{ toPlay.length }}首) </span></span>
       </div>
       <div class="listRight">
         <svg class="icon" aria-hidden="true">
           <use xlink:href="#icon-jia-copy"></use>
         </svg>
         <span v-if="!isLiked" @click="liked">+收藏({{ subscribed }})</span>
         <span v-else @click="liked" class="quxiao">-取消({{ subscribed -1}})</span>
       </div>
     </div>

     <div class="itemList">
       <div class="item" v-for="(item,i) of toPlay" :key="i">
         <div class="itemLeft" @click="playMusic(i)">
           <span class="leftSpan">{{ i + 1 }}</span>
           <div class="d-flex ai-center">
             <div class="d-flex ai-center ml-3">
               <div class="d-flex flex-column">
                 <p>{{ item.name }}</p>
                 <div>
                   <span
                       v-for="(item1, index) in item.ar"
                       :key="index"
                      >{{ item1.name }}|</span>
                 </div>
               </div>

               <svg
                   class="icon bofang pr-1"
                   aria-hidden="true"
                   v-if="item.fee === 1"
               >
                 <use xlink:href="#icon-tipvip"></use>
               </svg>
             </div>
           </div>
         </div>
         <div class="itemRight">
           <svg
               class="icon bofang"
               aria-hidden="true"
               v-if="item.mv !== 0"
           >
             <use xlink:href="#icon-bofang1"></use>
           </svg>
           <svg class="icon liebiao" aria-hidden="true">
             <use xlink:href="#icon-caidan"></use>
           </svg>
         </div>
       </div>
     </div>
   </div>
</template>

<script>
import {mapMutations, mapState} from "vuex";

export default {
  name: "ItemMusicList",
  props:{
    'toPlay':"",
    'subscribed':"",
  },
  data(){
    return{
       isLiked:false
    }
  },
  computed:{
    ...mapState(["playList","playIndex","isPlayed"])
  },
  methods:{
    playMusic(i){
      this.UPDATE(false)
      this.LIST(this.toPlay)
      this.INDEX(i)
    },
    ...mapMutations(["UPDATE","LIST","INDEX"]),
    liked(){
      this.isLiked=!this.isLiked;
    },
    PlayAll(){
      this.UPDATE(false)
      this.LIST(this.toPlay)
      this.INDEX(0)
      const audio=document.documentElement.querySelector('audio')
      audio.play()
    }
  },
  setup(props){

  },
  mounted() {
    // this.LIST(this.toPlay)
  }
}
</script>
<style lang="less" scoped>
.itemMusicList {
  width: 100%;
  height: 10rem;
  background-color: #fff;
  padding: 0 0.2rem;
  margin-top: 0.2rem;
  border-top-left-radius: 0.4rem;
  border-top-right-radius: 0.4rem;
  font-size: 10px;
  .itemListTop {
    width: 100%;
    height: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .listLeft {
      width: 3rem;
      height: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .quanbu{
        background-color: aquamarine;
        width: 120px;
        height: 70%;
        font-size: 8px;
        margin-left: 0;
        padding: 0.2rem;
        border-radius: 0.4rem;
      }
      .icon {
        stroke: #333333;
        stroke-width: 20;
      }
      span {
        font-weight: 700;
        span {
          font-weight: 400;
          font-size: 0.24rem;
          color: #999;
        }
      }
    }
    .listRight {
      display: flex;
      align-items: center;
      background-color: red;
      width: 130px;
      height: 70%;
      padding: 0.2rem;
      border-radius: 0.4rem;
      color: #fff;
      justify-content: center;

      .icon {
        width: 0.3rem;
        height: 0.3rem;
        fill: #fff;
        margin-right: 0.1rem;
        stroke: #fff;
        stroke-width: 50;
      }
    }
  }
  .itemList {
    width: 100%;
    .item {
      width: 100%;
      height: 1.4rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .itemLeft {
        width: 85%;
        height: 100%;
        display: flex;
        align-items: center;
        .leftSpan {
          display: inline-block;
          width: 0.2rem;
          text-align: center;
        }
        div {
          p {
            width: 4.54rem;
            height: 0.4rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-weight: 700;
          }
          span {
            font-weight: 400;
            font-size: 0.24rem;
            color: #999;
          }
        }
      }
      .itemRight {
        width: 20%;
        height: 100%;
        display: flex;
      // justify-content: space-between;
        align-items: center;
        position: relative;
        .icon {
          fill: #999;
        }
        .bofang {
          position: absolute;
          left: 0;
        }
        .liebiao {
          position: absolute;
          right: 0;
        }
      }
    }
  }
}
</style>
